package org.example;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/8/23
 * Time: 14:32
 */
public class Solution {
    public int takeAttendance(int[] records) {
        int left = 0,right = records.length - 1,mid = right / 2;
        while(left < right) {
            if (records[mid] == mid){
                left = mid + 1;
            }else{
                right = mid;
            }
            mid = left + (right - left) / 2;
        }
        return (records[left] == left) ? left + 1 : left;
    }
    public static void main(String[] args) {
        Solution solution = new Solution();
        int ret = solution.takeAttendance(new int[]{0, 1, 2, 3, 4, 5, 6});
        System.out.println(ret);
    }
}